// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

export component TestCase {
    in-out property <bool> condition: true;
    if condition: Text {
        x: 24px;
        y: 32px;
        width: 124px;
        height: 240px;
        accessible-role: text;
        accessible-label: "testlabel";
        accessible-value <=> self.text;
        text: "Ok";
        accessible-action-set-value(v) => {
            self.accessible-value = v;
        }
        accessible-action-default => {
            self.text = "default";
            self.accessible-label = "err";
        }
    }
}

/*
```rust
use slint::{LogicalSize, LogicalPosition};
let instance = TestCase::new().unwrap();
let mut label_search = slint_testing::ElementHandle::find_by_accessible_label(&instance, "testlabel");
let label = label_search.next().unwrap();
assert!(label.is_valid());
assert_eq!(label.accessible_label().unwrap(), "testlabel");
assert_eq!(label.accessible_value().unwrap(), "Ok");
label.set_accessible_value("newvalue");
assert_eq!(label.accessible_value().unwrap(), "newvalue");
label.invoke_accessible_default_action();
assert_eq!(label.accessible_value().unwrap(), "default");
assert_eq!(label.size(), LogicalSize::new(124., 240.));
assert_eq!(label.absolute_position(), LogicalPosition::new(24., 32.));

instance.set_condition(false);

// Trigger re-evaluation of the item tree traversal and thus re-evaluation of the repeater
slint_testing::send_mouse_click(&instance, 5., 5.);
assert!(!label.is_valid());
assert!(label.accessible_label().is_none());
label.set_accessible_value("noop");
label.invoke_accessible_default_action();
assert_eq!(label.size(), LogicalSize::default());
assert_eq!(label.absolute_position(), LogicalPosition::default());
```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;

auto label_search = slint::testing::ElementHandle::find_by_accessible_label(handle, "testlabel");
assert_eq(label_search.size(), 1);
auto label = label_search[0];

assert(label.is_valid());
assert_eq(*label.accessible_label(), "testlabel");
assert_eq(*label.accessible_value(), "Ok");
label.set_accessible_value("newvalue");
assert_eq(*label.accessible_value(), "newvalue");
label.invoke_accessible_default_action();
assert_eq(*label.accessible_value(), "default");
assert(label.size() == slint::LogicalSize({124., 240.}));
assert(label.absolute_position() == slint::LogicalPosition({24., 32.}));

instance.set_condition(false);

// Trigger re-evaluation of the item tree traversal and thus re-evaluation of the repeater
slint_testing::send_mouse_click(&instance, 5., 5.);
assert(!label.is_valid());
assert(!label.accessible_value().has_value());
label.set_accessible_value("newvalue");
label.invoke_accessible_default_action();
assert(label.size() == slint::LogicalSize({0., 0.}));
assert(label.absolute_position() == slint::LogicalPosition({0., 0.}));
```
*/
